package studentsystem1;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MainForm extends JFrame implements ActionListener {

    JMenu mSystem = new JMenu("学生信息管理");
    JMenuItem mExit = new JMenuItem("退出");
    JMenuItem mExit1 = new JMenuItem("查看");
    JMenu mOperate = new JMenu("课程信息管理");
    JMenuItem mAdd = new JMenuItem("添加");
    JMenuItem mDel = new JMenuItem("删除");
    JMenuItem mModify = new JMenuItem("修改");
    JMenu mQuery = new JMenu("成绩信息管理");
    JMenuItem mName = new JMenuItem("按姓名查询");
    JMenuItem mScore = new JMenuItem("按成绩查询");
    JMenu mHelp = new JMenu("学期信息管理");
    JMenuItem mAbout = new JMenuItem("操作");
    JMenuItem mAbout1 = new JMenuItem("");
    JMenuBar mBar = new JMenuBar();

    MainForm() {
        super("学生成绩管理系统");
        MyPanel myPanel = new MyPanel();
        setSize(600,600);
        mSystem.add(mExit);
        mOperate.add(mAdd);
        mOperate.add(mDel);
        mOperate.add(mModify);
        mQuery.add(mName);
        mQuery.add(mScore);
        mHelp.add(mAbout);
        mBar.add(mSystem);
        mBar.add(mOperate);
        mBar.add(mQuery);
        mBar.add(mHelp);
        setJMenuBar(mBar);
        mExit.addActionListener(this);
        mAdd.addActionListener(this);
        mDel.addActionListener(this);
        mModify.addActionListener(this);
        mName.addActionListener(this);
        mScore.addActionListener(this);
        mAbout.addActionListener(this);
        setContentPane(myPanel);
        setVisible(true);

    }

    public void actionPerformed(ActionEvent ae) {
        if (ae.getSource() == mExit)
            System.exit(0);
        else if (ae.getSource() == mAbout)
            JOptionPane.showMessageDialog(this, "学生成绩管理系统\n对不起，功能暂时未开放\n功能有待完善\n\n", "期末作品", JOptionPane.INFORMATION_MESSAGE);
        else if (ae.getSource() == mAdd)
            new AddForm().setVisible(true);
        else if (ae.getSource() == mDel)
            new DeleteForm().setVisible(true);
        else if (ae.getSource() == mModify)
            new ModifyForm().setVisible(true);
        else if (ae.getSource() == mName)
            new NameQueryForm().setVisible(true);
        else if (ae.getSource() == mScore)
            new ScoreQueryForm().setVisible(true);
    }

    public static void main(String[] args) {
        new MainForm();
    }
}